#  Copyright  2009
#  @Author
#  Richard Changde Yin            e-mail yinchangde@hotmail.com
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; version 2 of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


sbin_PROGRAMS= collapsar

#bin_SCRIPTS = 	drizzledumpslow \
#		drizzled_safe 



collapsarincludedir = ${includedir}/include

noinst_LTLIBRARIES = \
		libhandler.la \
		libserialutil.la\
		libsysutil.la

LDADD = $(top_builddir)/libclient/libclient.la \
	$(LIBZ) $(LIBINTL) ${LIBC_P}

collapsar_LDADD = ${noinst_LTLIBRARIES} \
		 $(top_builddir)/mainsrc/serialize/libserialize.la \
		 @sql_plugin_libs@ \
		 $(LDADD) $(LIBUUID) ${top_builddir}/gnulib/libgnu.la \
		 $(LIBDL_LIBS) $(LIBPROTOBUF) $(LIBPCRE) $(LIBTBB) \
		 $(COLLAPSAR_PLUGIN_DEP_LIBS)
collapsar_DEPENDENCIES = @sql_plugin_libs@ ${noinst_LTLIBRARIES}

collapsar_LDFLAGS =


collapsar_SOURCES = \
		bucketList.cc \
		bucket_tree.cc\
		cached_item.cc \
		calendar.cc \
		catalogTables.cc\
		check_stack_overrun.cc \
		chunk.cc\
		chunkiterator.cc\
		comp_creator.cc \
		config.cc \
		current_session.cc \
		database.cc\
		databaseManagerImpl.cc\
		debug.cc\
		decimal.cc\
		diagnostics_area.cc \
		dtcollation.cc \
		errmsg.cc \
		errmsg_print.cc \
		field/blob.cc \
		field/date.cc \
		field/datetime.cc \
		field/enum.cc \
		field/decimal.cc \
		field/double.cc \
		field/int64_t.cc \
		field/long.cc \
		field/longstr.cc \
		field/null.cc \
		field/num.cc \
		field/real.cc \
		field/str.cc \
		field/timestamp.cc \
		field/varstring.cc \
		field.cc \
		field_conv.cc \
		field_iterator.cc \
		foreign_key.cc \
		function/ascii.cc \
		function/additive_op.cc \
		function/benchmark.cc \
		function/bit.cc \
		function/bit_count.cc \
		function/char_length.cc \
		function/check_reserved_words.cc \
		function/connection_id.cc \
		function/coercibility.cc \
		function/field.cc \
		function/find_in_set.cc \
		function/found_rows.cc \
		function/func.cc \
		function/get_system_var.cc \
		function/get_user_var.cc \
		function/get_variable.cc \
		function/last_insert.cc \
		function/length.cc \
		function/locate.cc \
		function/min_max.cc \
		function/num1.cc \
		function/numhybrid.cc \
		function/num_op.cc \
		function/row_count.cc \
		function/set_user_var.cc \
		function/shift.cc \
		function/sign.cc \
		function/signed.cc \
		function/update_hash.cc \
		function/units.cc \
		function/unsigned.cc \
		function/user_var_as_out_param.cc \
		function/user_var_entry.cc \
		function/math/abs.cc \
		function/math/acos.cc \
		function/math/asin.cc \
		function/math/atan.cc \
		function/math/ceiling.cc \
		function/math/cos.cc \
		function/math/decimal_typecast.cc \
		function/math/divide.cc \
		function/math/exp.cc \
		function/math/floor.cc \
		function/math/int_divide.cc \
		function/math/integer.cc \
		function/math/int.cc \
		function/math/int_val.cc \
		function/math/ln.cc \
		function/math/log.cc \
		function/math/minus.cc \
		function/math/mod.cc \
		function/math/multiply.cc \
		function/math/neg.cc \
		function/math/ord.cc \
		function/math/plus.cc \
		function/math/pow.cc \
		function/math/rand.cc \
		function/math/real.cc \
		function/math/round.cc \
		function/math/sin.cc \
		function/math/sqrt.cc \
		function/math/tan.cc \
		function/str/alloc_buffer.cc \
		function/str/binary.cc \
		function/str/char.cc \
		function/str/charset.cc \
		function/str/collation.cc \
		function/str/concat.cc \
		function/str/conv.cc \
		function/str/conv_charset.cc \
		function/str/database.cc \
		function/str/elt.cc \
		function/str/export_set.cc \
		function/str/format.cc \
		function/str/hex.cc \
		function/str/insert.cc \
		function/str/left.cc \
		function/str/load_file.cc \
		function/str/make_set.cc \
		function/str/pad.cc \
		function/str/quote.cc \
		function/str/repeat.cc \
		function/str/replace.cc \
		function/str/reverse.cc \
		function/str/right.cc \
		function/str/set_collation.cc \
		function/str/str_conv.cc \
		function/str/strfunc.cc \
		function/str/substr.cc \
		function/str/sysconst.cc \
		function/str/trim.cc \
		function/str/user.cc \
		function/str/uuid.cc \
		function/str/weight_string.cc \
		function/time/curdate.cc \
		function/time/date.cc \
		function/time/date_add_interval.cc \
		function/time/date_format.cc \
		function/time/dayname.cc \
		function/time/dayofmonth.cc \
		function/time/extract.cc \
		function/time/dayofyear.cc \
		function/time/from_days.cc \
		function/time/from_unixtime.cc \
		function/time/get_interval_value.cc \
		function/time/hour.cc \
		function/time/last_day.cc \
		function/time/makedate.cc \
		function/time/microsecond.cc \
		function/time/minute.cc \
		function/time/month.cc \
		function/time/now.cc \
		function/time/quarter.cc \
		function/time/period_add.cc \
		function/time/period_diff.cc \
		function/time/second.cc \
		function/time/sysdate_local.cc \
		function/time/timestamp_diff.cc \
		function/time/to_days.cc \
		function/time/typecast.cc \
		function/time/unix_timestamp.cc \
		function/time/weekday.cc \
		function/time/year.cc \
		heap/d_list.cc\
		heap/ha_heap.cc \
		heap/hp_block.cc \
		heap/hp_clear.cc \
		heap/hp_close.cc \
		heap/hp_create.cc \
		heap/hp_delete.cc \
		heap/hp_dspace.cc \
		heap/hp_extra.cc \
		heap/hp_hash.cc \
		heap/hp_info.cc \
		heap/hp_open.cc \
		heap/hp_panic.cc \
		heap/hp_record.cc \
		heap/hp_rectest.cc \
		heap/hp_rename.cc \
		heap/hp_rfirst.cc \
		heap/hp_rkey.cc \
		heap/hp_rlast.cc \
		heap/hp_rnext.cc \
		heap/hp_rprev.cc \
		heap/hp_rrnd.cc \
		heap/hp_rsame.cc \
		heap/hp_scan.cc \
		heap/hp_static.cc \
		heap/hp_update.cc \
		heap/hp_write.cc \
		ha_trx_info.cc \
		hashIndex.cc\
		hybrid_type_traits.cc \
		hybrid_type_traits_decimal.cc \
		hybrid_type_traits_integer.cc \
		index_hint.cc \
		index.cc \
		item/bin_string.cc \
		item/cache.cc \
		item/cache_decimal.cc \
		item/cache_int.cc \
		item/cache_real.cc \
		item/cache_row.cc \
		item/cache_str.cc \
		item/cmpfunc.cc \
		item/copy_string.cc \
		item/create.cc \
		item/decimal.cc \
		item/direct_ref.cc \
		item/empty_string.cc \
		item/field.cc \
		item/float.cc \
		item/hex_string.cc \
		item/insert_value.cc \
		item/int_with_ref.cc \
		item/ident.cc \
		item/int.cc \
		item/null.cc \
		item/num.cc \
		item/outer_ref.cc \
		item/param.cc \
		item/ref.cc \
		item/ref_null_helper.cc \
		item/row.cc \
		item/string.cc \
		item/subselect.cc \
		item/sum.cc \
		item/type_holder.cc \
		item/uint.cc \
		item.cc \
		key.cc \
		lock.cc \
		lockManager.cc\
		logger.cc \
		lookup_symbol.cc \
		main.cc\
		mutex.cc\
		name_resolution_context_state.cc \
		natural_join_column.cc \
		opt_range.cc \
		opt_sum.cc \
		os.cc\
		pageInfo.cc \
		plugin_registry.cc \
		plugin_registry_impl.cc \
		process.cc\
		protocol.cc \
		query_id.cc \
		rb_tree.cc\
		records.cc \
		rename.cc \
		scheduling.cc \
		session.cc \
		set_var.cc \
		show.cc \
		sj_tmp_table.cc \
		sql_base.cc \
		sql_builtin.cc \
		sql_connect.cc\
		sql_delete.cc \
		sql_derived.cc \
		sql_error.cc \
		sql_insert.cc \
		sql_lex.cc \
		sql_list.cc \
		sql_locale.cc \
		sql_parse.cc \
		sql_plugin.cc \
		sql_select.cc \
		sql_state.cc \
		sql_string.cc \
		sql_table.cc \
		sql_udf.cc \
		sql_union.cc \
		sql_update.cc \
		sql_yacc.cc \
		stacktrace.cc \
		strfunc.cc \
		table.cc \
		table_map_iterator.cc \
		temporal.cc \
		temporal_format.cc \
		thr_lock.cc\
		thr_malloc.cc \
		transaction.cc\
		transactionManager.cc\
		treeIndex.cc\
		tztime.cc \
		uniques.cc \
		virtual_column_info.cc \
		xid.cc


libserialutil_la_SOURCES = table_proto_write.cc
libserialutil_la_CXXFLAGS= ${AM_CXXFLAGS} ${PROTOSKIP_WARNINGS}

libhandler_la_SOURCES = handler.cc mm_handler.cc

libsysutil_la_SOURCES = array.cc\
						bmove_upp.cc\
						charset.cc \
						charset-def.cc\
						ctype.cc\
						ctype-bin.cc\
						ctype-mb.cc\
						ctype-simple.cc\
						ctype-extra.cc\
						ctype-uca.cc\
						ctype-utf8.cc\
						db_error.cc\
						db_getopt.cc\
						db_init.cc\
						db_static.cc\
						db_strtoll10.cc\
						db_thr_init.cc\
						db_getsystime.cc\
						db_time.cc\
						error.cc \
						filesort.cc\
						hash.cc\
						dtoa.cc\
						int2str.cc\
						is_prefix.cc\
						llstr.cc\
						longlong2str.cc\
						my_access.cc\
						my_alloc.cc\
						my_bit.cc\
						my_bitmap.cc\
						my_decimal.cc\
						mulalloc.cc\
						mf_qsort.cc\
						mf_qsort2.cc\
						str2int.cc\
						typelib.cc\
						time_util.cc \
						util_lib.cc\
						util_iocache.cc\
						util_iocache2.cc\
						util.cc


AM_YFLAGS = -p COLLAPSAR -d --verbose


if BUILD_GCC_PCH
PCHHEADERS = \
		definitions.h.gch \
		sql_base.h.gch \
		sql_parse.h.gch \
		sql_plugin.h.gch \
		util/convert.h.gch \
		util/test.h.gch
else
PCHHEADERS = 
endif

BUILT_MAINT_SRC = sql_yacc.cc \
		  sql_yacc.h

BUILT_SOURCES = $(BUILT_MAINT_SRC) \
		symbol_hash.h \
		function_hash.h \
		$(PCHHEADERS)

EXTRA_DIST = \
		$(BUILT_MAINT_SRC) \
		symbol_hash.gperf \
		function_hash.gperf \
		message.mc 

CLEANFILES = \
		configmake.h \
		${top_builddir}/include/function_hash.h \
		function_hash.stamp-h \
		build_sql_yacc \
		${top_builddir}/include/symbol_hash.h \
		symbol_hash.stamp-h \
		$(PCHHEADERS) \
		$(nodist_collapsar_SOURCES)

DISTCLEANFILES = $(EXTRA_PROGRAMS) \
		 $(BUILT_MAINT_SRC)

MAINTAINERCLEANFILES = $(BUILT_MAINT_SRC)



SUFFIXES = .gch .gperf .stamp-h

if BUILD_GCC_PCH
.h.gch:
	$(CXXCOMPILE) -include config.h ${NO_UNUSED_MACROS} -c $<
endif


sql_yacc.cc: build_sql_yacc
sql_yacc.h: build_sql_yacc

build_sql_yacc:
	@if test -f ${top_builddir}/include/sql_yacc.h ; then \
		rm  ${top_builddir}/include/sql_yacc.h ; \
	fi
	$(YACC) -d sql_yacc.yy;\
	mv y.tab.c sql_yacc.cc ;\
	mv y.tab.h ${top_builddir}/include/sql_yacc.h 
	@if test -f ${top_builddir}/include/sql_yacc.h ; then touch $@ ; fi


function_hash.h: function_hash.stamp-h
symbol_hash.h: symbol_hash.stamp-h

function_hash.stamp-h:
	$(GPERF) --initializer-suffix=,0 --struct-type --enum \
		--omit-struct-type --readonly-tables --language=C++ \
		--class-name=$* ${top_builddir}/include/$*.gperf  > $@
	@if ! test $$? ; then rm $@ ; fi
	@if test -f $@ ; then \
		if ! diff $@ \
			   ${top_builddir}/include/$*.h >/dev/null 2>&1 ; \
		then \
			cp $@ ${top_builddir}/include/$*.h ; \
		fi \
	fi

symbol_hash.stamp-h:
	$(GPERF) --initializer-suffix=,0 --struct-type --enum \
		--omit-struct-type --readonly-tables --language=C++ \
		--class-name=$* ${top_builddir}/include/$*.gperf  > $@
	@if ! test $$? ; then rm $@ ; fi
	@if test -f $@ ; then \
		if ! diff $@ \
			   ${top_builddir}/include/$*.h >/dev/null 2>&1 ; \
		then \
			cp $@ ${top_builddir}/include/$*.h ; \
		fi \
	fi
